#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar shi,ge,number;
uchar code table[]={
0xC0,0xf9,0xA4,0xB0,
0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,
0xC6,0xA1,0x86,0x8E};
sbit fmq=P3^6;
sbit P2_2=P2^2;
sbit P2_3=P2^3;
sbit k0=P2^4;
sbit k1=P2^5;
void delay(uint z);
void shownum(uchar shi,uchar ge,uchar cyc,uchar time);
void main()
{
	k0=1;
	k1=1;
	while(1)
	{
		if(k0==0)
		{
			number++;
			shi=number%100/10;
			ge=number%10;
			while(!k0)
			{
				shownum(shi,ge,50,5);
			}
		}
		else
		{
			if(k1==0)
			{
			number--;
			shi=number%100/10;
			ge=number%10;
			while(!k1)
			{
				shownum(shi,ge,20,5);
			}
			}
			else
			{
				shownum(shi,ge,50,5);
			}
		}
	}
}
void delay (uint z)
{
	uint x,y;
	for(x=z;x>0;x--)
		for(y=11;y>0;y--);
}
void shownum(uchar shi,uchar ge,uchar cyc,uchar time)
{
uchar xh;
for(xh=0;xh<cyc;xh++)
		{
			//sg
			P0=table[shi];
			P2_2=0;
			delay(time);
			P2_2=1;
			P0=table[ge];
			P2_3=0;
			delay(time);
			P2_3=1;
		}
}